let id = 0;
export function getUid() {
    return `${id++}`;
}

export const noop = () => { };

export function error(location, message) {
    console.error(`[Vue3 BaiduMap GL/${location}]: ${message}`);
}

export function bindEvents(props, VueEmit, instance) {
    for (const key of Object.keys(props)) {
        if (/^on/.test(key) && props[key]) {
            const _key = key.replace(/^on/, '').toLocaleLowerCase();
            instance.addEventListener(_key, (e) => {
                var _a, _b;
                e.preventDefault = e.preventDefault || ((_a = e.domEvent) === null || _a === void 0 ? void 0 : _a.preventDefault.bind(e.domEvent));
                e.stopPropagation = e.stopPropagation || ((_b = e.domEvent) === null || _b === void 0 ? void 0 : _b.stopPropagation.bind(e.domEvent));
                VueEmit(_key, e);
            });
        }
    }
}

export const isDef = (val) => typeof val !== 'undefined';

export function warn(location, message) {
    console.warn(`[Vue3 BaiduMap GL/${location}]: ${message}`);
}

export function conditionalCall(conditionalFlagGetter, trulyCall, falselyCall) {
    return (arg) => (conditionalFlagGetter() ? trulyCall(arg) : falselyCall(arg));
}

export function callWhenDifferentValue(cal) {
    return (nv, ov) => {
        if (nv === ov || (nv !== ov && JSON.stringify(nv) !== JSON.stringify(ov)))
            cal(nv);
    };
}